import { createApp } from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'

// 1. 引入 css
import  "@/styles/index.scss"

// 2. 引入 element-plus 
import ElementPlus from "element-plus"
import 'element-plus/dist/index.css'

// 3.mixins
import {commonMixins} from "@/utils/mixins"

import moment from "moment"
const app  = createApp(App);
// 全局过滤器
app.config.globalProperties.$filters = {
  prefix(url) {
    if (url && url.startsWith('http')) {
      return url
    } else {
      url = `http://backend-api-01.newbee.ltd${url}`
      return url
    }
  },
  timeFormat(value,format){
      if(!value) return value;
      // console.log(value)
      format = format || "YYYY-MM-DD"
      return moment(value).format(format)
  },
  telformat(value,str){
    if(!value) return '';
    str = str || '-';
    value = value.toString().split("");
    value.splice(3,0,str);
    value.splice(8,0,str);
    return value.join("")
}
}
  app
  .mixin(commonMixins)
  .use(ElementPlus)
  .use(store)
  .use(router)
  .mount('#app')
